//
//  BaseViewModel.h
//  CommunityCircle
//
//  Created by 毕武侠 on 16/3/5.
//  Copyright © 2016年 ssyx. All rights reserved.
//

#import <Foundation/Foundation.h>

// An base class representing a view model
@interface BaseViewModel : NSObject

/**
 *  Initialization method. This is the preferred way to create a new view model
 *
 *  @param params   The parameters to be passed to view model
 *
 *  @return a new view model
 */
- (instancetype)initWithParams:(SGParameter *)params;
- (instancetype)initWithUrl:(NSString *)url;
- (instancetype)initWithUrl:(NSString *)url withParams:(SGParameter *)params;

@property (nonatomic, strong) NSString    *url;
@property (nonatomic, strong) SGParameter *params;
@property (nonatomic, strong) RACCommand  *command;
@property (nonatomic, copy)   NSString    *msg;

/// A RACSubject object, which representing all errors occurred in view model.
@property (nonatomic, strong, readonly) RACSubject *errors;
@property (nonatomic, strong, readonly) RACSubject *willDisappearSignal;

@property (nonatomic, assign) BOOL shouldFetchLocalDataOnViewModelInitialize;
@property (nonatomic, assign) BOOL shouldRequestRemoteDataOnViewDidLoad;    // 是否在viewDidLoad时加载数据
/// An additional method, in which you can initialize data, RACCommand etc.
///
/// This method will be execute after the execution of `-initWithServices:params:` method. But
/// the premise is that you need to inherit `MRCViewModel`.
- (void)initialize;

@end
